#pragma once

#include "Common.h"

class CentralCache //单例模式
{
public:
	static CentralCache* GetInstance() { return &_Inst;}

	// 从SpanList中获取一个Span
	Span* GetOneSpan(SpanList& list, size_t size);

	// 从CentralCache中获取一定数量的块给ThreadCache,返回实际拿到的块数量
	size_t FetchRangeBlock(void*& start, void*& end, size_t BatchNum, size_t size);

	// 释放链表到对应的span
	void ReleaseListToSpans(void* start, size_t size);

private:
	CentralCache() {}

	CentralCache(const CentralCache&) = delete; // 拷贝和赋值禁用
	CentralCache& operator==(const CentralCache&) = delete;

	SpanList _spanlist[NFREELIST];

	static CentralCache _Inst;
};
